home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
352_01
/
veczrect.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-22
|
749b
|
34 lines
//////// COMPLEX VECTORS
//
// VECZRECT.CPP - rectify a complex vector in polar form.
// this involves checking magnitudes for negative values
// which might occur after some scalar to complex operations.
//
//
#include <stdlib.h>
#include <alloc.h>
#include <string.h>
#include "wtwg.h"
#include "dblib.h"
#include "vector.h"
void CVector::rectify(void)
{
if ( !ispolar ) return;
int vn = x.n;
float *vm = x.v, *va = y.v; // mag and angle arrays.
float temp;
while ( --vn >= 0 )
{
if ( (temp =vm[vn]) < 0 )
{
vm[vn] = -temp; // make mag. positive.
va[vn] += PI; // add PI to phase.
}
}
}
//----------------------end of VECZRECT.CPP -------------------------